home *** CD-ROM | disk | FTP | other *** search
- *** foldmisc.c Thu Jul 18 11:22:38 1991
- --- e:\tc\origami\src\tos\foldmisc.c Mon Jul 29 10:17:52 1991
- ***************
- *** 9,14 ****
- --- 9,15 ----
- # include <stat.h> /* needed for struct stat */
- # include <errno.h>
- # include <tos.h>
- + #define FOLDMISC_C
- # include "..\fold\fold_os.h"
- /*}}} */
-
- ***************
- *** 153,155 ****
- --- 154,167 ----
- version by Eric R. Smith if you wich to use these routines.
- */
- /*}}} */
- +
- + char *newgetcwd(char *buf, int buflen)
- + {
- + char *s;
- + s = getcwd(buf,buflen);
- + /* make sure there is no '\' at the end of the string */
- + s+=strlen(s);
- + if (s>buf && s[-1] == '\\')
- + s[-1] = 0;
- + return buf;
- + }
- *** keybutil.c Thu Jul 18 11:22:40 1991
- --- e:\tc\origami\src\tos\keybutil.c Sun Jul 21 22:18:08 1991
- ***************
- *** 12,14 ****
- --- 12,26 ----
- system(command);
- }
- /*}}} */
- + #include <stdio.h>
- + /*{{{ FILE *newfopen(const char *filename, const char *mode)*/
- + FILE *newfopen(const char *filename, const char *mode)
- + {
- + FILE *stream;
- +
- + stream = fopen(filename,mode);
- + if (stream != NULL)
- + setvbuf(stream,NULL,_IOFBF,10240L);
- + return stream;
- + }
- + /*}}} */
- *** st_utils.c Thu Jul 18 11:22:42 1991
- --- e:\tc\origami\src\tos\st_utils.c Wed Jul 31 14:47:56 1991
- ***************
- *** 13,18 ****
- --- 13,19 ----
- # include <tos.h>
- # include <vdi.h>
- # include <aes.h>
- + #include "local\argparse.h"
- # include "ori_rsc.h"
-
- # define ST_UTIL_C
- ***************
- *** 92,97 ****
- --- 93,99 ----
- /*{{{ void newexit (int status) - replacement for library exit() function*/
- void newexit (int status)
- {
- + int result,dummy,mbuf[16];
- /*
- it seems that we first have to get our messages before quitting the
- program in order to avoid problems - so we use get_raw_key() instead
- ***************
- *** 98,105 ****
- of Cconin()
- */
- if (status != 0)
- ! while(get_raw_key() != 13)
- ! ;
- exit(status);
- }
- /*}}} */
- --- 100,124 ----
- of Cconin()
- */
- if (status != 0)
- ! {
- ! do
- ! /*{{{ evnt_multi */
- ! result = evnt_multi(MU_MESAG|MU_TIMER, 0,
- ! 0,0,
- ! 0,0,
- ! 0,0,
- ! 0,0,
- ! 0,0,
- ! 0,0,
- ! mbuf, 1000,
- ! 0, &dummy,
- ! &dummy, &dummy,
- ! &dummy, &dummy,
- ! &dummy );
- ! /*}}} */
- ! while (result & MU_MESAG);
- ! Cconin();
- ! }
- exit(status);
- }
- /*}}} */
- ***************
- *** 122,127 ****
- --- 141,155 ----
- appl_exit();
- }
- /*}}} */
- + private int no_bak_files = 0; /* set by cmd line argument */
- + /*{{{ os_argtab[]*/
- + #define os_argnum 1
- +
- + private ARG os_argtab[os_argnum] =
- + {
- + 'B', BOOL_ARG, &no_bak_files
- + };
- + /*}}} */
- /*{{{ void st_init(int *argc, char **argv[])*/
- void st_init(int *argc, char **argv[])
- {
- ***************
- *** 244,249 ****
- --- 272,279 ----
- }
- /*}}} */
- *argv[0] = "origami";
- + /* parse argv for additional, OS-specific arguments */
- + *argc=argparse(*argc,*argv,os_argtab,os_argnum);
- }
- /*}}} */
-
- ***************
- *** 336,369 ****
- /*}}} */
- /*{{{ void putenv(char *string) - set environment variables*/
- /*
- ! This implementation of putenv simply does a system("setenv ..."). This
- ! works well with MUPFEL, it should also work with other shells which stay
- ! resident in the background while executing ORIGAMI and which maintain
- ! one global environment for all sub-shells. Has anyone a better idea of
- ! how to do this ?
- */
- void putenv(char *string)
- {
- ! char buf[256];
- ! char *p=buf;
- !
- ! /* build command: setenv var "value" from string var=value */
- ! strcpy(buf,"setenv ");
- while (*p)
- p++;
- ! while (*string && *string != '=')
- ! *p++ = *string++;
- ! string++;
- ! *p++ = ' ';
- ! *p++ = '"';
- ! while (*string)
- ! *p++ = *string++;
- ! *p++ = '"';
- ! *p = 0;
- system(buf);
- }
- /*}}} */
- - int no_bak_files = 0; /* global, set by cmd line argument */
- /*{{{ FILE *newfopen(const char *filename, const char *mode)*/
- FILE *newfopen(const char *filename, const char *mode)
- {
- --- 366,436 ----
- /*}}} */
- /*{{{ void putenv(char *string) - set environment variables*/
- /*
- ! Since system() calls the shell in memory which has started ORIGAMI, we
- ! cannot simply write to the environment. As a replacement, we do a
- ! system() call with something like 'setenv "var=value"' - this will set
- ! the shell's environment. The only problem is that the command may not
- ! contain some special characters - eg '"'. In order to make this work
- ! with every shell without recompilation, this part of ORIGAMI can be
- ! configures by setting two environment variables before starting ORIGAMI:
- ! SHELL_SETENV and SHELL_SETCONV. If these are not set, a default will be
- ! used which works with MUPFEL.
- !
- ! SHELL_SETENV contains the string which is passed to sprintf(). It may
- ! contain 2 ocurrences of %s - the first is the environment variable to
- ! set and the second is the new value. "%s=%s" will produce something like
- ! "var=value", "setenv %s=\"%s\"" will produce something like "setenv
- ! var=\"val\"" etc.
- !
- ! SHELL_SETCONV controlls character substitution in 'val'. It may contain
- ! pairs of characters - every ocurrence of the first character in a set is
- ! replaced by the second one.
- */
- void putenv(char *string)
- {
- ! char buf[256],
- ! *val = string,
- ! *p,*p2,
- ! *format = getenv("SHELL_SETENV"),
- ! *convert = getenv("SHELL_SETCONV");
- !
- ! /*{{{ environment: set defaults if necessary*/
- ! if (format == NULL)
- ! format = "%s=\"%s\"";
- ! if (convert == NULL)
- ! convert = "\" ";
- ! /*}}} */
- ! /*{{{ split up string into var. and value to set*/
- ! while (*val && *val != '=')
- ! val++;
- ! if (*val == 0)
- ! return;
- ! *val = 0;
- ! val++;
- ! /*}}} */
- ! /*{{{ parse value and interpret SHELL_SETCONV to filter invalid chars*/
- ! p = val;
- while (*p)
- + {
- + p2 = convert;
- + while(p2[0] && p2[1])
- + {
- + if (*p2 == *p)
- + {
- + *p = *++p2;
- + break;
- + }
- + p2 += 2;
- + }
- p++;
- ! }
- ! /*}}} */
- ! /*{{{ build shell command, execute shell*/
- ! sprintf(buf,format,string,val);
- system(buf);
- + /*}}} */
- }
- /*}}} */
- /*{{{ FILE *newfopen(const char *filename, const char *mode)*/
- FILE *newfopen(const char *filename, const char *mode)
- {
-